package com.oscchina.xushao.common;

import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;

/**
 * 简单的两列Tab事件监听器，实现了ActionBar.TabListener接口
 */
public class SimpleTwoTabsListener implements ActionBar.TabListener {

	private ViewPager viewPager;

	public SimpleTwoTabsListener(ViewPager viewPager) {
		this.viewPager = viewPager;
	}

	@Override
	public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
		if (viewPager != null && viewPager.getCurrentItem() != tab.getPosition()) {
			viewPager.setCurrentItem(tab.getPosition());
		}
	}

	@Override
	public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {

	}

	@Override
	public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {

	}

}
